package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.util.StringTokenizer;

public class P2261 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2261.class.getResource("P2261.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String[] country = new String[16]; 
		for (int i = 0; i < country.length; i ++) {
			country[i] = stdin.readLine().trim();
			while (country[i].length() < 11) country[i] += " ";
		}
		
		double[][] p = new double[16][];
		for (int i = 0; i < p.length; i ++) {
			p[i] = new double[16];
			StringTokenizer st = new StringTokenizer(stdin.readLine());
			for (int j = 0; j < p[i].length; j ++) {
				p[i][j] = Double.valueOf(st.nextToken())/100.00f;
			}
		}
		DecimalFormat f = new DecimalFormat("##0.00");
		for (int i = 0; i < p.length; i ++) {
			System.out.println(country[i] + "p=" + f.format(calc(p, i)*100.0) + "%");
		}
	}
	
	private static double calc(double[][] p, int winner) {

		if (p.length == 2) {
			return p[winner][1-winner];
		} else {
			int n = p.length/2;
			double[][] p1 = new double[n][];
			double[][] p2 = new double[n][];
			for (int i = 0; i < n; i ++) {
				p1[i] = new double[n];
				p2[i] = new double[n];
				for (int j = 0; j < n; j ++) {
					p1[i][j] = p[i][j];
					p2[i][j] = p[i+n][j+n];
				}
			}
			
			double x = 0.0f;
			if (winner >= n) {
				double s = calc(p2, winner-n);
				for (int i = 0; i < n; i ++) {
					x += calc(p1, i)*p[winner][i];
				}
				x *= s;
			} else {
				double s = calc(p1, winner);
				for (int i = 0; i < n; i ++) {
					x += calc(p2, i)*p[winner][i+n];
				}
				x *= s;
			}
			return x;
		}
	}
}